﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using SAKS.Models;

namespace SAKS.Services.Query
{
    class PagedMessageSentSearch : PagedQueryOverBase<MessageSent>
    {
        public PagedMessageSentSearch(ISession session) : base(session) { }

        public string From { get; set; }

        protected override IQueryOver<MessageSent, MessageSent> GetQuery()
        {
            var query = Session.QueryOver<MessageSent>();
            if (!string.IsNullOrEmpty(From))
                query = query.Where(m => m.FromName == From);
            query = query.OrderBy(m => m.Date).Desc;
            return query;
        }
    }
}
